package com.junbao.androidinterview.proxy.dongtai;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 *    author : Majunbao
 *    github : https://github.com/MaJunBaox
 *    time   : 2022/8/9 12:20 下午
 *    desc   : 动态代理
 */

public class DynamicProxyLawyer implements InvocationHandler {

    //代理的真实对象
    private Object subject;

    public DynamicProxyLawyer(Object subject) {
        this.subject = subject;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
        before();
        method.invoke(subject,objects);
        after();
        return null;
    }

    private void before() {
        System.out.println("签合同");
    }
    private void after() {
        System.out.println("收佣金");
    }
}
